package com.java.web.servlet;

import com.java.service.UserService;
import com.java.service.impl.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class UserServlet {
    public static void main(String[] args) {
//        在项目的根目录开始查找
//        ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");

//        在磁盘路径开始查找
        ApplicationContext app = new FileSystemXmlApplicationContext("E:\\JAVASE\\14-Spring\\day-01-loc\\src\\main\\resources\\applicationContext.xml");

//        通过id名进行查找,可以写多个相同bean
//        UserService userService = (UserService) app.getBean("userService");

//        通过class类型进行查找,类必须是唯一性
        UserService userService = app.getBean(UserService.class);

//        调用方法
        userService.login();
    }
}
